//
//  NoticeWebViewController.m
//  随便点
//
//  Created by ZC on 15/4/8.
//  Copyright (c) 2015年 qfsoft. All rights reserved.
//

#import "NoticeWebViewController.h"

@interface NoticeWebViewController ()

@end

@implementation NoticeWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.hidesBackButton = YES;
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed: @"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = item;
    
    //显示通知标题
    [self setUpTitle];
    
    //显示通知内容
    [self setUpNotes];

}
-(void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 显示通知内容

-(void)setUpNotes{

    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.51anys.com:8080/waimaiwang/notice/message"]];
    NSString *postStr=@"";
    [request setHTTPMethod:@"post"];
    NSData *data=[postStr dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data];
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError){
        NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        [self performSelectorOnMainThread:@selector(refreshData2:) withObject:str waitUntilDone:YES];

    }];
    
}


#pragma mark - 显示通知标题

-(void)setUpTitle{
    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.51anys.com:8080/waimaiwang/notice/title"]];
    NSString *postStr=@"";
    [request setHTTPMethod:@"post"];
    NSData *data=[postStr dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data];
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError){
        NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        [self performSelectorOnMainThread:@selector(refreshData1:) withObject:str waitUntilDone:YES];
        
        
    }];
}
-(void)refreshData2:(NSString *)html{
    
    [self.NoticeWebView loadHTMLString:html baseURL:nil];

}
-(void)refreshData1:(NSString *)str1{
         
    self.TitleLabel.text=str1;
         
}



@end
